package com.api.shopapi.mapper;

import com.api.shopapi.entity.SBJSleepAlarm;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface SBJSleepAlarmMapper {

    @Insert("insert into sbj_sleep_alarm (SleepAlarmCode,HeaderCode,DeviceId,AlarmType,SendDateTime,AddTime) values " +
            "(#{sleepAlarm.SleepAlarmCode},#{sleepAlarm.HeaderCode},#{sleepAlarm.DeviceId},#{sleepAlarm.AlarmType},#{sleepAlarm.SendDateTime},#{sleepAlarm.AddTime})")
    int insert(@Param("sleepAlarm") SBJSleepAlarm sleepAlarm);

    @Select("select * from sbj_sleep_alarm where " +
            "DeviceId=#{deviceId} " +
            "and AddTime between #{startTime} and #{endTime} " +
            "order by AddTime desc")
    List<SBJSleepAlarm> getSleepAlarmPageByDeviceId(@Param("deviceId") String deviceId, @Param("startTime") String startTime, @Param("endTime") String endTime);
}
